package br.com.revenda.controle;

import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import br.com.revenda.modelo.Cargo;

@ManagedBean
@RequestScoped
public class CargoBean {

	Cargo cargoSelec = new Cargo();
	List<Cargo> lista;
	
	public String salvar(){
		CargoRN rn = new CargoRN();
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Cargo cadastrado com sucesso!!!"));
		rn.salvar(cargoSelec);
		return "listaCargo";
	}
	
	
	public void deletar(){
		CargoRN rn = new CargoRN();
		rn.deletar(cargoSelec);
	}
	
	public String altera(){
		CargoRN rn = new CargoRN();
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Cargo alterado com sucesso!!!"));
		rn.alterar(cargoSelec);
		return "ListaCargo";
	}
	
	
	public List<Cargo> listarTodos(){
		CargoRN rn = new CargoRN();
		lista = rn.listarTodos();
		return lista;
	}
	
	
	public Cargo getCargoSelec() {
		return cargoSelec;
	}

	public void setCargoSelec(Cargo cargoSelec) {
		this.cargoSelec = cargoSelec;
	}
	
	
	
	
	
	
	
	
	
}
